﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Attributes - Attr</title>
    <script src="script/jquery-1.3.2.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("div").attr("id", function(arr) {
                return "div-id" + arr[0];
            })
            .each(function() {
                $("span", this).html("(ID = '<b>" + this.id + "</b>')");
            });

            $("img").attr("src", function() {
                return "images/" + this.title;
            }); 

        });
    </script>
</head>
<body>
    <div>Zero-th <span></span></div> 
    <div>First <span></span></div> 
    <div>Second <span></span></div>
    
    <img title="logo.gif"/> 
</body>
</html>
